Developer Documentation

QuickTime 4 API Documentation

QuickTime 4 Reference

| Previous | Chapter Contents | Chapter Top | Next |

Creating a Sequence Grabber Component that Captures Multiple Files

You can create a sequence grabber component that can capture to multiple files by doing the following in your sequence grabber component:

An example of how to do this is shown in Listing 1 . This example also shows how to use the SGAddOutputDataRefToMedia helper routine to easily manage the multiple files in which the captured data is stored.

Listing 1 Channel capture and managing multiple output files

Track aTrack = NewMovieTrack(theMovie, width, height, 0);
Media aMedia = NewTrackMedia(aTrack, TextMediaType,
                        kMediaTimeScale, nil, 0);
SeqGrabExtendedFrameInfo fi;
SGOutput lastOutput = nil;
long i;
OSErr err;
fi.frameChannel = store->self;
i = -1;
do {
    TimeValue frameDuration;
    err = SGGetNextExtendedFrameReference(store->grabber, &fi,
            &frameDuration, &i);
            if (err) {
                if (err == paramErr)
                err = noErr;
                break;
            }
    // switch to the next data reference
    if (lastOutput != fi.frameOutput) {
        err = SGAddOutputDataRefToMedia(store->grabber,
            fi.frameOutput, aMedia, sampleDescription);
        if (err) goto exit;
        lastOutput = fi.frameOutput;
    }
    //note that only the low 32 bits of the file offset are used here
    err = AddMediaSampleReference(aMedia,
            fi.frameOffset.lo, fi.frameSize,
            frameDuration,
            sampleDescription, 1,
            0, 0);
} while (err == noErr);
exit:
    if (alias) DisposeHandle((Handle)alias);
    return err;

In this example, the default data reference is not defined when NewTrackMedia is called. Instead, the default data reference is defined by the first call to SGAddOutputDataRefToMedia . This approach provides added flexibility by allowing movies to be captured to data handlers other than the standard file system data handler.


© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |